load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])

# See rs/nervous_system/feature_test.md
BASE_DEPENDENCIES = [
    # Keep sorted.
    "//packages/icrc-ledger-client:icrc_ledger_client",
    "//packages/icrc-ledger-types:icrc_ledger_types",
    "//rs/canister_client/sender",
    "//rs/config",
    "//rs/crypto/sha2",
    "//rs/ledger_suite/common/ledger_canister_core",
    "//rs/ledger_suite/common/ledger_core",
    "//rs/ledger_suite/icp:icp_ledger",
    "//rs/ledger_suite/icrc1",
    "//rs/ledger_suite/icrc1/index-ng",
    "//rs/ledger_suite/icrc1/ledger",
    "//rs/nervous_system/clients",
    "//rs/nervous_system/common",
    "//rs/nervous_system/common/test_keys",
    "//rs/nervous_system/root",
    "//rs/nns/constants",
    "//rs/rust_canisters/canister_test",
    "//rs/rust_canisters/dfn_candid",
    "//rs/rust_canisters/dfn_protobuf",
    "//rs/rust_canisters/on_wire",
    "//rs/sns/governance",
    "//rs/sns/init",
    "//rs/sns/root",
    "//rs/sns/swap",
    "//rs/state_machine_tests",
    "//rs/types/base_types",
    "//rs/types/management_canister_types",
    "//rs/types/types",
    "//rs/utils",
    "@crate_index//:candid",
    "@crate_index//:futures",
    "@crate_index//:lazy_static",
    "@crate_index//:maplit",
    "@crate_index//:num-traits",
    "@crate_index//:prost",
    "@crate_index//:tokio",
]

# Each target declared in this file may choose either these (release-ready)
# dependencies (`DEPENDENCIES`), or `DEPENDENCIES_WITH_TEST_FEATURES` feature previews.
DEPENDENCIES = BASE_DEPENDENCIES + [
    "//rs/nns/test_utils",
]

DEPENDENCIES_WITH_TEST_FEATURES = BASE_DEPENDENCIES + [
    "//rs/nns/test_utils:test_utils--test_feature",
]

MACRO_DEPENDENCIES = [
    # Keep sorted.
    "@crate_index//:async-trait",
]

DEV_DEPENDENCIES = []

MACRO_DEV_DEPENDENCIES = []

ALIASES = {}

rust_library(
    name = "test_utils",
    testonly = True,
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    crate_name = "ic_sns_test_utils",
    proc_macro_deps = MACRO_DEPENDENCIES,
    version = "0.9.0",
    deps = DEPENDENCIES,
)

rust_library(
    name = "test_utils--test_feature",
    testonly = True,
    srcs = glob(["src/**/*.rs"]),
    aliases = ALIASES,
    crate_features = ["test"],
    crate_name = "ic_sns_test_utils",
    proc_macro_deps = MACRO_DEPENDENCIES,
    version = "0.9.0",
    deps = DEPENDENCIES_WITH_TEST_FEATURES,
)

rust_test(
    name = "test_utils_test",
    testonly = True,
    aliases = ALIASES,
    crate = ":test_utils",
    proc_macro_deps = MACRO_DEPENDENCIES + MACRO_DEV_DEPENDENCIES,
    deps = DEPENDENCIES + DEV_DEPENDENCIES,
)
